//
//  MFNewFetureViewCell.m
//  MFLive_iOS
//
//  Created by 邓建 on 2019/4/30.
//  Copyright © 2019 邓建. All rights reserved.
//

#import "MFNewFetureViewCell.h"
#import "JHLoginViewController.h"
@interface MFNewFetureViewCell ()
@property (nonatomic, weak) UIImageView *imageView;

@property (nonatomic, weak) UIButton *startButton; //开始按钮

@end
@implementation MFNewFetureViewCell
- (UIButton *)startButton
{
    if (_startButton == nil) {
        UIButton *startBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [startBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        startBtn.frame=CGRectMake(100, 80, 200, 40);
        startBtn.backgroundColor=[UIColor redColor];
        startBtn.clipsToBounds=YES;
        startBtn.layer.cornerRadius=20;
        [startBtn setTitle:@"开始" forState:UIControlStateNormal];;
        [startBtn addTarget:self action:@selector(start) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:startBtn];
        _startButton = startBtn;
    }
    return _startButton;
}

- (UIImageView *)imageView
{
    if (_imageView == nil) {
        
        UIImageView *imageV = [[UIImageView alloc] init];
        imageV.contentMode=UIViewContentModeScaleAspectFill;
        imageV.clipsToBounds=YES;
        _imageView = imageV;
        
        // 注意:一定要加载contentView
        [self.contentView addSubview:imageV];
    }
    return _imageView;
}

// 布局子控件的frame
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.imageView.frame = self.bounds;
    
    
    
    // 开始按钮
    self.startButton.center = CGPointMake(self.width * 0.5, self.height-50 );
}

- (void)setImage:(UIImage *)image
{
    _image = image;
    
    self.imageView.image = image;
}



// 判断当前cell是否是最后一页
- (void)setIndexPath:(NSIndexPath *)indexPath count:(int)count
{
    if (indexPath.item == count-1 ) { // 最后一页,显示开始按钮
        
        self.startButton.hidden = NO;
        
    }else{ // 非最后一页，开始按钮
        self.startButton.hidden = YES;
    }
}


- (void)start
{
 
    JHLoginViewController *vc=[[JHLoginViewController alloc]init];
    [UIApplication sharedApplication].keyWindow.rootViewController=vc;
    
}

@end
